/*
 * Created on Jun 7, 2005
 *
 */
package com.erclab.internal.xpresso.webapp;



import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.erclab.internal.xpresso.Application;
import com.erclab.internal.xpresso.exceptions.ApplicationException;

import org.apache.log4j.*;

/**
 * @author Enrique Rodriguez.
 *
 */
public class WebAppListener implements ServletContextListener {

	// Create the log for this class
	private static final Logger log = Logger.getLogger(WebAppListener.class);

	/* (non-Javadoc)
	 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent event) {
		// Initialize the application
		log.info("xpresso Application starting ...");
		Application xpresso = null;
		try {
			xpresso = new Application();
		} catch(ApplicationException e){
			log.fatal("Create Application failed: " + e.toString());
		}
		ServletContext sc = event.getServletContext();
		log.info("xpresso Application: " + xpresso.getApplicationName());
		log.info("xpresso Application Description: " + xpresso.getApplicationDescription());
		log.info("xpresso Application started succesfully.");
		log.info("Server info: " + sc.getServerInfo());
	}

	/* (non-Javadoc)
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent arg0) {
		// Nothing to do here		
	}

}
